﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using CoderJoe.WoW.Services;
using Microsoft.Practices.Unity;
using CoderJoe.WoW.GearManager;

namespace CoderJoe
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        public static Workspace CurrentWorkspace
        {
            get
            {
                App app = (Current as App);
                if(app != null)
                    return app.Workspace;

                return null;
            }
        }

        public Workspace Workspace { get; private set; }

        protected override void OnStartup(StartupEventArgs e)
        {
            Workspace = new Workspace();

            Workspace.RegisterType<ItemService>(new ContainerControlledLifetimeManager());
            Workspace.RegisterType<CharacterService>(new ContainerControlledLifetimeManager());
            Workspace.RegisterType<CharacterController>(new ContainerControlledLifetimeManager());
            Workspace.RegisterType<ItemToolTipController>(new ContainerControlledLifetimeManager());
            Workspace.RegisterType<EquipmentButtonController>(new ContainerControlledLifetimeManager());
            Workspace.RegisterType<LoadCharacterController>();
			Workspace.RegisterType<CharacterModel>(new ContainerControlledLifetimeManager());

            Workspace.Resolve<CharacterController>().Load("Medivh", "Essiaa");

            base.OnStartup(e);
        }

        protected override void OnExit(ExitEventArgs e)
        {
            Workspace.Dispose();
            Workspace = null;

            base.OnExit(e);
        }
    }
}
